﻿using Itech_Run.Sys.Domain.Entity;
using Itech_Run.Sys.Domain.IRepository;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;

namespace Itech_Run.Sys.EntityFrameworkCore.Repository
{
    public class Sys_UserRepository : EfCoreRepository<Itech_RunSysContext, Sys_User, string>, ISys_UserRepository
    {
        private IDbContextProvider<Itech_RunSysContext> _dbContext;

        public Sys_UserRepository(IDbContextProvider<Itech_RunSysContext> dbContextProvider) : base(dbContextProvider)
        {
            _dbContext = dbContextProvider;
        }

        public async Task EntryUserRole(Sys_User entity)
        {
            (await _dbContext.GetDbContextAsync()).Entry(entity).State = EntityState.Modified;
            (await _dbContext.GetDbContextAsync()).Entry(entity).Collection(u => u.Sys_UserRole).Load();
        }
    }
}
